package com.a01_2021.thousandstimes.general.mapper;

import com.a01_2021.thousandstimes.general.entity.ExperienceDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author E1xP
 * @since 2021-03-27
 */
public interface ExperienceDetailMapper extends BaseMapper<ExperienceDetail> {

    @Select("SELECT DISTINCT time from experience_detail where experience_id=#{experienceId} ORDER BY time")
    List<LocalDate> getDate(long experienceId);

    @Select("SELECT score from experience_detail where experience_id=#{experienceId} AND ability_id=9 ORDER BY time")
    List<Double> getOverAllScore(long experienceId);

    @Insert("<script>" +
            "INSERT INTO experience_detail (user_id, experience_id, ability_id, score, time) values " +
            "<foreach item='item' collection='list' index='index' separator=','>" +
            "(#{item.userId},#{item.experienceId},#{item.abilityId},#{item.score},#{item.time})" +
            "</foreach>" +
            "</script>")
    void insertList(List<ExperienceDetail> list);
}
